package com.member.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.member.mapper.StudentMapper;
import com.member.po.Student;
import com.member.service.StudentService;

public class StudentServiceImpl implements StudentService{
	@Autowired
	private StudentMapper studentMapper;

	//对传来的map容器进行处理
	public void setMap(Map map){
		if(map==null){
			return;
		}
		int pageNum = (int) map.get("pageNum");
		int size = (int) map.get("size");
		int startNum = (pageNum-1)*size;
		map.put("startNum", startNum);
	}
	
	@Override
	public Student selectById(int id) {
		return studentMapper.selectById(id);
	}

	@Override
	public void insert(Student clazz) {
		studentMapper.insert(clazz);
	}

	@Override
	public void updateById(Student clazz) {
		studentMapper.updateById(clazz);
	}

	@Override
	public void deleteById(int id) {
		studentMapper.deleteById(id);
	}

	@Override
	public int countRows(Map map) {
		this.setMap(map);
		return studentMapper.countRows(map);
	}
	
	@Override
	public List<Student> select(Map map) {
		this.setMap(map);
		//模糊查询检测
		if(map!=null && map.get("param")!=null){
			map.put("studentId", map.get("param"));
			map.put("studentName", map.get("param"));
		}
		return studentMapper.select(map);
		
	}

}